while True:
    str = input("请输入一个字符串:")
    if len(str) > 31:
        print("字符串长度大于31，请重新输入")
        continue
    else:
        print("-" * 50)
        print("您输入的字符串:", str)
        break

print("长度:", len(str))

print("逆序后为",str[len(str): : -1])

d = {}
for letter in str:
    if letter not in d:
        d[letter] = 1
    else:
        d[letter] += 1




print("字符统计结果:{}".format(d))
print("-" * 50)